﻿using System;
using System.Collections.Generic;
using UnityEngine;
public class HeartBeatModify:GameModifyBase
{
    private float DelayTime = 2;
    private float waitTime = 0;

    private int missionIdx = 0;

    private List<Action> seqAction = new List<Action>();
    public override void InitByGameLevel(IGGameLevelMgr gameLevel)
    {
        base.InitByGameLevel(gameLevel);
        var ActorFactory = gameLevel.ActorFactory;
        var ActorManager = gameLevel.ActorManager;
        var actorMarkOne = ActorFactory.CreateMarkOne();
        ActorManager.AddActor(actorMarkOne);
        var ident = actorMarkOne.Ident;
        seqAction.Add(() => {
            var actor = ActorManager.GetActorByIdent(ident);
            actor.Name = "Mark hello kity";
            Debug.Log("changeNameMarkone .");
        });
        seqAction.Add(() => {
            var actor = ActorManager.GetActorByIdent(ident);
            ActorManager.RemoveActor(actor);
            ActorFactory.RecycleActor(actor);
            Debug.Log("remove mark one.");
        });
        seqAction.Add(() => {
            Debug.Log("done.");
        });

    }

    public override void Tick()
    {
        base.Tick();
        waitTime += Time.deltaTime;
        if (waitTime>=DelayTime) 
        {
            if (missionIdx<seqAction.Count) 
            {
                var action = seqAction[missionIdx];
                action.Invoke();
                missionIdx++;
            }
            waitTime = 0;
        }
    }
}
